<template>
  <div class="user-item">
    <img  class="avatar" :src="user.avatar" alt="" >
    <div class="info border-bottom-1px">
      <span class="name">{{user.name}}  {{levels[user.levelId]}}</span>
      <span class="code">{{user.code}}  {{user.mobile}}</span>
    </div>
<!--    <div class="act" @click.stop="act(user)" v-if="user.status==1">-->
<!--      未激活-->
<!--    </div>-->
<!--    <div class="act" @click.stop="act(user)" v-if="user.status==0&&!user.vip">-->
<!--      未兑费-->
<!--    </div>-->
  </div>
</template>

<script>
import { options } from '@/api/level'
import { LEVELS } from '@/const'
import { act } from '@/api/user'
import { showAlert } from '@/dialog'

export default {
  name: 'index',
  props: {
    user: Object
  },
  methods: {
    act (user) {
      // 不是药店
      if (user.levelId !== LEVELS.SHOP && !user.levelId !== LEVELS.CUSTOM) {
        return
      }
      act(user.id).then(res => {
        showAlert('操作成功')
        this.user = res.data
      })
    }
  },
  created () {
    options().then(res => {
      this.levels = res.data.levelOptions
    })
  },
  data () {
    return {
      levels: []
    }
  }
}
</script>

<style scoped lang="stylus">
  .user-item
    display flex
    align-items center
    height 60px
    background-color #FFFFFF
    .act
      margin-right 40px
      width:40px;
      height:20px;
      color red
      dpr-font(10Px)
      display flex
      align-items center
      justify-content center
    .avatar
      width 40px
      height 40px
      border-radius 5px
      flex 0 40px
      margin 0 15px
    .info
      display flex
      flex-direction column
      flex 1
      justify-content center
      align-items flex-start
      border-bottom-color #DCDCDC
      height 100%
      .name
        font-size:13px;
        font-family:PingFang SC;
        font-weight:300;
        color:rgba(78,61,7,1);
        line-height 13px
      .code
        margin-top 6px
        font-size:11px;
        font-family:PingFang SC;
        font-weight:300;
        color:rgba(161,161,161,1);

</style>
